﻿using System.ComponentModel;
using Microsoft.Xna.Framework;
using XNAComponents;
using System;
using System.ComponentModel.Design;
namespace XNAComponentsTemplate
{
    delegate void Initializer();
    delegate void Updater(GameTime gameTime);

    [Designer(typeof(XnaGameComponentDesigner),typeof(IDesigner))]
    partial class GameComponentComponent:IComponent
    {
        public GameComponentComponent()
        {
        }

        public GameComponentComponent(IContainer container)
        {
            container.Add(this);
        }

        private XnaGame game;

        public XnaGame Game
        {
            get { return game; }
            set
            {
                game = value;
                xnaComponent = new XnaGameComponent(game);
                xnaComponent.Init = Initialize;
                xnaComponent.Updater = Update;
            }
        }


        private XnaGameComponent xnaComponent;

        [Browsable(false)]
        public XnaGameComponent XnaComponent
        {
            get { return xnaComponent; }
            set { xnaComponent = value; }
        }

        #region IComponent Membres

        public event System.EventHandler Disposed;

        private ISite site;

        [Browsable(false)]
        public ISite Site
        {
            get { return site; }
            set { site = value; }
        }


        #endregion

        #region IDisposable Membres

        public void Dispose()
        {
            if (Disposed != null)
                Disposed(this, EventArgs.Empty);
        }

        #endregion
    }
}
